// See the Electron documentation for details on how to use preload scripts:
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts

import { contextBridge, ipcRenderer } from 'electron';

// 为window对象添加electronAPI类型声明
declare global {
  interface Window {
    electronAPI: {
      readModelConfig: (modelName: string) => Promise<any>;
      writeModelConfig: (modelConfig: any) => Promise<{success: boolean; error?: string}>;
    }
  }
}

contextBridge.exposeInMainWorld('electronAPI', {
  // 文件操作API
  readModelConfig: (modelName: string) => ipcRenderer.invoke('read-model-config', modelName),
  writeModelConfig: (modelConfig: any) => ipcRenderer.invoke('write-model-config', modelConfig)
});
